<template>
	<view>
		<view class="header row">
			<text>{{jifen}}</text>
			<span>当前积分</span>
		</view>
		<view class="question">如何获取积分?</view>
		<view class="item flex">
			<image :src="imgurl+'jf_user.png'"></image>
			<view class="item-center">
				<view class="center-top">登录({{loginFen}}/10)</view>
				<view class="center-bottom">每次积10分,每天最多累积10分</view>
			</view>
			<view class="item-right">已完成</view>
		</view>
		<view class="item flex">
			<image :src="imgurl+'je_wenjuan.png'"></image>
			<view class="item-center">
				<view class="center-top">看卷({{readFen}}/100)</view>
				<view class="center-bottom">每次看卷积1分,每天最多看100分</view>
			</view>
			<view class="item-right" @tap="navTo">去完成</view>
		</view>
		<view class="item flex">
			<image :src="imgurl+'jf_dajuan.png'"></image>
			<view class="item-center">
				<view class="center-top">答卷({{answerFen}}/1000)</view>
				<view class="center-bottom">每次提交答卷积10分,每天最多1000分</view>
			</view>
			<view class="item-right" @tap="navTo">去完成</view>
		</view>
		<view class="item flex">
			<image :src="imgurl+'fenxiang.png'"></image>
			<view class="item-center">
				<view class="center-top">分享({{shareFen}}/10000)</view>
				<view class="center-bottom">分享一次问卷增加10积分,每天最多10000分</view>
			</view>
			<view class="item-right" @tap="navToShare">去完成</view>
		</view>
	</view>
</template>

<script>
	import api from "@/common/api.js";
	import {
		baseURL
	} from "@/common/http.js";
	import app from "../../../App.vue"
	export default {
		data() {
			return {
				imgurl: "",
				jifen: 0,
				dl: 0,
				num2: 0,
				num3: 0,
				num4: 0,
				loginFen: 0,
				shareFen: 0,
				readFen: 0,
				answerFen: 0
			};
		},
		methods: {
			navTo() {
				uni.navigateTo({
					url: '../../questionHAall/questionHAall'
				})
			},
			navToShare() {
				uni.reLaunch({
					url: '../../index/index'
				})
			}
		},
		onShareAppMessage(options) {
			let shareObj = {
				success: (res) => {
					if (res.errMsg == 'shareAppMessage:ok') {
						uni.showToast({
							title: '分享成功',
							icon: 'success',
							duration: 1500
						})
					}
				},
				fail: () => {
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						uni.showToast({
							title: '取消分享',
							icon: 'none',
							duration: 2000
						})
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				},
				complete: () => {
					// 转发结束之后的回调（转发成不成功都会执行）
				}
			}
		},
		onLoad() {
			this.imgurl = app.globalData.imgurls
		},
		onShow() {
			let data = {
				api: 'wenfenzong',
				id: uni.getStorageSync('message')[0].id
			}
			api.look(data).then(res => {
				if (res.code == 200) {
					this.loginFen = res.date['1']
					this.shareFen = res.date['4']
					this.answerFen = res.date['3']
					this.readFen = res.date['2']
					this.jifen = res.date.fen
				}
			}).catch(err => {
				console.log(err)
			})
		}
	}
</script>

<style lang="scss">
	.header {
		height: 350rpx;
		width: 100%;
		background: #209FFC;
		color: #fff;
		text-align: center;
		box-sizing: border-box;
		padding-top: 90rpx;

		text {
			font-size: 138rpx;
			font-weight: 400;
		}

		span {
			font-size: 30rpx;
			font-weight: 500;
		}
	}

	.question {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		background: #F0F0F0;
		padding-left: 30rpx;
		box-sizing: border-box;
		color: #666;
		font-size: 30rpx;
		font-weight: 400;
	}

	.item {
		width: 690rpx;
		height: 130rpx;
		border-bottom: 1rpx solid #EEEEEE;
		margin: 0 auto;

		image {
			width: 50rpx;
			height: 50rpx;
			margin-right: 10rpx;
		}

		.item-center {
			width: 75%;
			margin-top: 10rpx;

			.center-top {
				font-size: 32rpx;
				font-weight: 500;
				color: #333;
			}

			.center-bottom {
				font-size: 20rpx;
				font-size: 500;
				color: #666;
				margin: 10rpx 0;
			}
		}

		.item-right {
			width: 100rpx;
			height: 50rpx;
			line-height: 50rpx;
			text-align: center;
			color: #209FFC;
			border: 1rpx solid #209FFC;
			border-radius: 16rpx;
			font-size: 24rpx;
			font-weight: 500;
		}
	}
</style>
